class FeedsController < ApplicationController  
  before_filter :login_required
  layout "admin", :only => [:index, :new]
  #in_place_edit_for :feed, :tag_regexp
    
  def index
    @feeds = Feed.find(:all)    
  end

  def set_tag_regexp
    @feed = Feed.find(params[:id])
    @feed.tag_regexp = params[:tag_regexp]
    @feed.save!
    render :text => @feed.tag_regexp    
  end
  
  def new
    @feed = Feed.new
  end

  def edit
    @feed = Feed.find(params[:id])
  end
  
  def create
    @feed = Feed.new params[:feed]
    if @feed.save
      @feed.receive
      flash[:notice] = 'Feed subscription was successfully created.'
    end
    redirect_to(:controller => "settings", :action => "index")  
  end

  def destroy
    feed = Feed.find(params[:id])
    feed.destroy
    redirect_to(:controller => "settings", :action => "index")
  end

  def receive
    @feed = Feed.find(params[:id])
    @feed.receive
    #render :action => "receive", :layout => false
  end
  
end

